home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / ext / events / write_cover.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  3KB  |  73 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. import os
  5. import shutil
  6. from gi.repository import Gtk
  7. from quodlibet import config
  8. from quodlibet.const import USERDIR
  9. from quodlibet.plugins.events import EventPlugin
  10.  
  11. def get_path():
  12.     out = os.path.join(USERDIR, 'current.cover')
  13.     return config.get('plugins', __name__, out)
  14.  
  15.  
  16. def set_path(value):
  17.     config.set('plugins', __name__, value)
  18.  
  19.  
  20. class PictureSaver(EventPlugin):
  21.     PLUGIN_ID = 'Picture Saver'
  22.     PLUGIN_NAME = _('Picture Saver')
  23.     PLUGIN_DESC = _('The cover image of the current song is saved to a file.')
  24.     PLUGIN_ICON = Gtk.STOCK_SAVE
  25.     PLUGIN_VERSION = '0.21'
  26.     
  27.     def plugin_on_song_started(self, song):
  28.         outfile = get_path()
  29.         if song is None:
  30.             
  31.             try:
  32.                 os.unlink(outfile)
  33.             except EnvironmentError:
  34.                 pass
  35.             
  36.  
  37.         cover = song.find_cover()
  38.         if cover is None:
  39.             
  40.             try:
  41.                 os.unlink(outfile)
  42.             except EnvironmentError:
  43.                 pass
  44.             
  45.  
  46.         f = file(outfile, 'wb')
  47.         f.write(cover.read())
  48.         f.close()
  49.  
  50.     
  51.     def PluginPreferences(self, parent):
  52.         
  53.         def changed(entry):
  54.             fn = entry.get_text()
  55.             
  56.             try:
  57.                 shutil.move(get_path(), fn)
  58.             except EnvironmentError:
  59.                 pass
  60.  
  61.             set_path(fn)
  62.  
  63.         hb = Gtk.HBox(spacing = 6)
  64.         hb.set_border_width(6)
  65.         hb.pack_start(Gtk.Label(label = _('File:')), False, True, 0)
  66.         e = Gtk.Entry()
  67.         e.set_text(get_path())
  68.         e.connect('changed', changed)
  69.         hb.pack_start(e, True, True, 0)
  70.         return hb
  71.  
  72.  
  73.